package fictional.Common;

import java.util.SortedSet;
import java.util.TreeSet;

public class Messages extends SocialElement<MessageItem>{

	public Messages(CharacterItem character) {
		this.character = character;
	}
	/**
	 * Sets the supplied messages collection into this message board
	 * @param messages The messages collection
	 */
	public void setMessages(SortedSet<MessageItem> messages) {
		collection = messages;
	}
	/**
	 * Gets all messages in this message board
	 * @return All messages, sorted
	 */
	public SortedSet<MessageItem> getAllMessages() {
		return collection;
	}
	/**
	 * Gets all unread messages in this message board
	 * @return All unread messages, sorted
	 */
	public SortedSet<MessageItem> getUnreadMessages() {
		SortedSet<MessageItem> ret = new TreeSet<MessageItem>();
		for (MessageItem message : collection) {
			if (!message.isRead()) {
				ret.add(message);
			}
		}
		return ret;
	}
	/**
	 * Deletes a message from this message board
	 * @param message The message
	 */
	public void deleteMessage(MessageItem message) {
		removeItem(message);
	}
	/**
	 * Adds a message to this message board
	 * @param message The message
	 */
	public void addMessage(MessageItem message) {
		addItem(message);
	}
}
